package main

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

/**
 * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
 *
 * @param pRoot TreeNode类
 * @return int整型二维数组
 */
func Print(pRoot *TreeNode) [][]int {
	NC14dfs(pRoot, 0)
	return NC14ans
}

var NC14ans = make([][]int, 0)

func NC14dfs(pRoot *TreeNode, num int) {
	if pRoot == nil {
		return
	}
	if len(NC14ans) == num {
		NC14ans = append(NC14ans, []int{})
	}
	if num%2 == 1 {
		NC14ans[num] = append(NC14ans[num], pRoot.Val)
	} else {
		NC14ans[num] = append([]int{pRoot.Val}, NC14ans[num]...)
	}
	if pRoot.Right != nil {
		NC14dfs(pRoot.Right, num+1)
	}
	if pRoot.Left != nil {
		NC14dfs(pRoot.Left, num+1)
	}
}
